<%@page import="bll.EnumName"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.util.*,util.*,dal.*,model.*, bll.*"%>
<%
	int idPlace = MiscUtil.getIntUrlParam(request, "idPlace");
	boolean hasPlace = false;
	String placeName = "Unknown";
// 	String placeUrl = "";
	
	if(idPlace != Integer.MIN_VALUE)
	{	
		placeName = CacheUtil.getPlaceName(idPlace);
// 		placeUrl = "place.jsp?id="+idPlace;
		hasPlace = true;
	}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Add New Venue</title>
<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/inputForm.css" />
<link rel="stylesheet" href="css/listForm.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css" type="text/css" />
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />
<link rel="stylesheet" href="css/datepicker.css" type="text/css" />
<link rel="stylesheet" href="css/themes/ui-lightness/jquery.ui.all.css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css" type="text/css" />
<link rel="stylesheet" href="css/jquery-datepicker.css" />
<link rel="stylesheet" href="css/jquery-dialog.css" />

<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.select.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.widget.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.timepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.js"></script>
<script language="javascript" type="text/javascript" src="js/ajaxQuickInsert.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.numeric.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.tools.min.js"></script>
<script language="javascript" type="text/javascript" src="js/common.js"></script>


<script language="javascript" type="text/javascript">
$(document).ready(pageLoaded);

function pageLoaded()
{
	turnOnNumbericInput();
	initTooltip();	
} 

var requiredInputs = [['name','name_required']];
var intInputs = [];
var doubleInputs = [];
var dateInputs = [];
var timeInputs = [];
var mailInputs = [['contact_email_1','contact_email_1_invalid'],['contact_email_2','contact_email_2_invalid']];


function checkInputs() {
	var valid = true;

	if (checkRequiredInputs(requiredInputs) == false) {
		valid = false;
	}
	if (checkMailInputs(mailInputs) == false) {
		valid = false;
	}

	// SPECIFIC VALIDATE CODE HERE		

	return valid;
}
	
	
</script>
</head>
<body>
	<div class="divContainer">
		<%@ include file="menu.jsp"%>
				<form id="inputForm" action="venue?mode=insert<%if(hasPlace){%>&id_place=<%=idPlace%><%} %>" method="post" onSubmit="return checkInputs()">
					<table class="tblInput">
					<% if(hasPlace){ %>
							<tr><td colspan="1">
								<b>Place:<%=placeName %></b>
							</td></tr>
						<% } %>
						<tr>
							<td class="inputHeader">ADD NEW VENUE</td>
						</tr>
						<tr>
					<td style="padding-left: 200px; padding-right: 200px;">
						<table cellspacing="0px">
						<% if(!hasPlace) { %>
							<tr><td colspan="3">									
										<center><i>(Select place in the below list)</i></center>
								</td>
								<td colspan="4"></td>
							</tr>
							
							<tr class="trField">
								<td class="tdFieldName">Place</td>
								<td class="tdFieldInput">
									<select id="id_place" name="id_place" class="hyjack" title="Choose a place for this venue.">
									<%=HtmlUtil.<PlaceModel>genModelSelect(CacheUtil.getPlaceList(), null)%>
									</select>
									<input class="btnAdd" type="button" id="addNewPlace" value="" onclick="ajaxAddItem('#id_place', 'place', 'name', 'Please enter new place name!');" title="Click here to add new place."/>
								</td>
								<td class="tdErrMsg">
								</td>					
						<% }else { %>
							<tr class="trField">
								<td></td>
								<td></td>
								<td></td>
							
						<% } %>	
						
							
							
							<td rowspan="8"></td>
							
							<td class="tdFieldName">Contact Person 1</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="contact_person_1" name="contact_person_1" maxlength="255" title="Name of contact person 1." />
							</td>
							<td class="tdErrMsg">
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Name</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="name" name="name" maxlength="255" title="Name of new venue. Note: Required." onblur="validateRequiredInput('name');"/>
							</td>
							<td class="tdErrMsg">
								<span id="name_required" class="errMsg" style="display: none;" title="Name is required.">(!)</span> 
								<span id="name_invalid" class="errMsg" style="display: none;" title="Name is invalid"></span>
							</td>
							
							<td class="tdFieldName">Telephone</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="contact_phone_1" name="contact_phone_1" maxlength="13" onkeydown="phoneNumberTextKeyDown(event, this);" onkeyup="phoneNumberTextKeyUp(this);" title="Phone number of contact person 1 . Format: (+)xxxxx..." />
							</td>
							<td class="tdErrMsg">
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Address</td>
							<td class="tdFieldInput">
								<textarea id="address" name="address" rows="5" class="inputTextarea" title="Address of new venue."></textarea>
							</td>
							<td class="tdErrMsg">
							</td>
							
							<td class="tdFieldName">Mobile</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="contact_mobile_1" name="contact_mobile_1" maxlength="13" onkeydown="phoneNumberTextKeyDown(event, this);" onkeyup="phoneNumberTextKeyUp(this);" title="Mobile number of contact person 1 . Format: (+)xxxxx..." />
							</td>
							<td class="tdErrMsg">
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Code</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="code" name="code" maxlength="20" title="Code of new venue." />
							</td>
							<td class="tdErrMsg">
							</td>
							
							<td class="tdFieldName">Email</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="contact_email_1" name="contact_email_1" maxlength="255" title="Email of contact person 1." onchange="validateMailInput('contact_email_1')" />
							</td>
							<td class="tdErrMsg">
								<span id="contact_email_1_invalid" class="errMsg" style="display: none;" title="The email you input is invalid">(!)</span> 
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Capacity</td>
							<td class="tdFieldInput">
								<input class="inputInt" type="text" id="capacity" name="capacity" maxlength="10" title="Capacity of new venue. Note: Integer only." />
							</td>
							<td class="tdErrMsg">
							</td>
							
							<td class="tdFieldName">Contact Person 2</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="contact_person_2" name="contact_person_2" maxlength="255" title="Name of contact person 2." />
							</td>
							<td class="tdErrMsg">
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Type</td>
							<td class="tdFieldInput">
								<select id="id_type" name="id_type" class="hyjack" title="Choose a type for this venue.">
								<%=HtmlUtil.<VenueTypeModel>genModelSelect(CacheUtil.getVenueTypeList(), null)%>
								</select>
								<input class="btnAdd" type="button" id="addNewIdType" value="" onclick="ajaxAddItem('#id_type', 'venueType', 'name', 'Please enter new venue type name!');" title="Click here to add new venue type."/>
							</td>
							<td class="tdErrMsg">
							</td>
							
							<td class="tdFieldName">Telephone</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="contact_phone_2" name="contact_phone_2" maxlength="13" onkeydown="phoneNumberTextKeyDown(event, this);" onkeyup="phoneNumberTextKeyUp(this);" title="Phone number of contact person 2 . Format: (+)xxxxx..." />
							</td>
							<td class="tdErrMsg">
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Fax</td>
							<td class="tdFieldInput">
								<input class="inputInt" type="text" id="fax" name="fax" maxlength="10" title="Fax number of new venue. Note: Integer only." />
							</td>
							<td class="tdErrMsg">
							</td>
							
							<td class="tdFieldName">Mobile</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="contact_mobile_2" name="contact_mobile_2" maxlength="13" onkeydown="phoneNumberTextKeyDown(event, this);" onkeyup="phoneNumberTextKeyUp(this);" title="Mobile number of contact person 2 . Format: (+)xxxxx..." />
							</td>
							<td class="tdErrMsg">
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Remark</td>
							<td class="tdFieldInput"><textarea id="remark" name="remark" rows="5" class="inputTextarea" title="Remark of new venue."></textarea>
							</td>
							<td class="tdErrMsg"></td>
							
							<td class="tdFieldName">Email</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" id="contact_email_2" name="contact_email_2" maxlength="255" title="Email of contact person 2." onchange="validateMailInput('contact_email_2')" />
							</td>
							<td class="tdErrMsg">
								<span id="contact_email_2_invalid" class="errMsg" style="display: none;" title="The email you input is invalid">(!)</span> 
							</td>
						</tr>	
						
						
						
						
						<tr class="trInputBottom">
							<td colspan="7" class="tdSubmit" style="text-align: center;"><input class="btnSubmit" type="submit" value="Submit" title="Click to save above information."/></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</form>
	<%
	
		String urlVenueList = "venueList.jsp?embedded=true" + (hasPlace == true ? "&idPlace=" + idPlace : "");
	%>
		<jsp:include page='<%=urlVenueList%>'></jsp:include>
	</div>
</body>
</html>